<?php

/**
 * @author phpadmin
 * @copyright 2012
 */

class Vendor extends CI_Controller {
    function __construct(){
        parent::__construct();
    }
    
    public function index(){
        $this->load->model('user_model');
        
        $res = $this->user_model->get_vendor_list();
        
        if($res != false)
        {
            foreach($res as $row)
            {
                $dlist[] = $row;
            }
        }
        
        $data['main_content'] = "vendor_view";
        $data['listview'] = $dlist;    
        $this->load->view('include/template', $data);
    }
    
    public function add_vendor_view()
    {
        
        $data['main_content'] = "vendoradd_view";
        $this->load->view('include/template', $data);
    }
    
    public function add_vendor_db()
    {
        $this->load->model('product_model');

        $this->product_model->add_new_vendor_db();
        
        redirect('vendor');
    }

    public function add_product_view()
    {
        $this->load->model('user_model');
        
        $res = $this->user_model->get_vendor_list();
        
        if($res != false)
        {
            foreach($res as $row)
            {
                $dlist[] = $row;
            }
        }
        
        $this->load->model('product_model');
        $res = $this->product_model->get_all_category();
        
        if($res != false)
        {
            foreach($res as $row)
            {
                $clist[] = $row;
            }
        }
        
        $data['main_content'] = "productadd_view";
        $data['vendorlist'] = $dlist;
        $data['catlist'] = $clist;    
        $this->load->view('include/template', $data);
    }
    
    public function add_product_db()
    {
        $this->load->model('product_model');
        
        $this->product_model->new_product_db();
        
        redirect('vendor');        
    }
    
    public function product_model_view()
    {
        $this->load->model('product_model');
        
        $res = $this->product_model->get_all_product_list();
        
        if($res != false)
        {
            foreach($res as $row)
            {
                $clist[] = $row;
            }
        }
        
        $data['main_content'] = "model_listview";
        $data['modellist'] = $clist;    
        $this->load->view('include/template', $data);
    }
}
